﻿using System;
using System.Collections.Generic;
using System.Web;

namespace FancyIdea.PingShui.Core.DbHelper
{
    public class SqlConditionUtil
    {
        public static void AddLikeCondition(List<string> conditionList, string para, string value)
        {
            conditionList.Add("" + para + " like '%" + value + "%'");
        }
        public static void AddEqualeCondition(List<string> conditionList, string para, string value)
        {
            conditionList.Add("" + para + "=" + value + "");
        }
        public static void AddDateRangeCondition(List<string> conditionList, string para, string start, string end)
        {
            if (string.IsNullOrEmpty(start) || string.IsNullOrEmpty(end)) return;
            try
            {
                DateTime endTime = DateTime.Parse(end);
                endTime = endTime.Date.AddDays(1);
                conditionList.Add("" + para + " between '" + start + "' and '" + endTime + "'");
            }
            catch
            {
                //忽略
            }
        }
    }
}